package com.fit.pages.professor;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.annotations.AdminAccess;
import com.fit.annotations.AnonymousAccess;
import com.fit.annotations.ProfessorAccess;
import com.fit.annotations.StudentAccess;
import com.fit.dao.homework.HomeworkDAO;
import com.fit.dao.professor.ProfessorDAO;
import com.fit.dao.user.UserDAO;
import com.fit.entities.homework.Homework;
import com.fit.entities.professor.Professor;
import com.fit.entities.user.User;
import com.fit.model.MD5;
import com.fit.pages.ErrorPage;
@AdminAccess
@AnonymousAccess
@ProfessorAccess
@StudentAccess
public class Add {

	@Property
	private Professor professor;
	@Inject
	private ProfessorDAO professorDAO;
	@InjectPage
	private ErrorPage errorPage;

	Object onSuccess() {
		try {
			professorDAO.save(professor);
			return Browse.class;
		} catch (Exception e) {
			errorPage.setMessage("Error while trying to add professor! ");
			return errorPage;
		}

	}

}
